< previous page page_73 next page >

Page 73
You can also set the MultiSelect property to 2-Extended. In this case, the list box acts like the Windows Explorer. If you click an item, it will be highlighted. Then, to highlight additional items, you have to hold down the Ctrl key and click. You can also select all items between the first one highlighted and the last one highlighted by holding down the Shift key. One more method is to click and hold your mouse and drag your mouse over the items you want to highlight. Of course you may find this last method a little harder to control.
EXERCISE
Try the Multi-Select Form
1. Change the MultiSelect property to 2-Extended.
2. Run the form and try highlighting items in different ways using the Ctrl and Shift keys.
analysis.gifYou can use many different methods to select items in a list box. Find which one works best for you!

You also have the option of setting the Style property to CheckBox. When this option is selected, a check box will appear next to each item in the list. You toggle a check box by clicking it.
EXERCISE
Using Check Boxes on a List Box to Select Multiple Items
1. Change the Style property to 1-Checkbox.
2. Change the Columns property back to 0.
3. Run the form and select different items by clicking check boxes. You will see an example of what this should look like in Figure 4.3.
analysis.gifAn internal list called Selected will be set to either a True or False value to represent which items are selected in the list when any of the preceding methods are used. Selected is actually a property that only exists at runtime. It will always have as many items in it as you have in the list itself. You can loop through this Selected property and perform processing on each of the selected items.

 
< previous page page_73 next page >

If you like this book, buy it!